﻿using System;
using System.Collections.Generic;
using ContractManager.Entity;
using Speed.Data;

namespace ContractManager.BLL.Business
{
    public static class ClsContractStatus
    {
        public static List<ContractStatus> SelectAll()
        {
            using (var db = Sys.NewDb())
            {
                return Data.Base.ContractStatus.Select(db);
            }
            
        }

        public static void Insert(ContractStatus capital)
        {
            using (var db = Sys.NewDb())
            {
                db.Insert<ContractStatus>(capital, EnumSaveMode.Requery);
            }
           
        }

        public static void Update(ContractStatus capital)
        {
            using (var db = Sys.NewDb())
            {
                db.Update<ContractStatus>(capital);
            }
            
        }

        public static ContractStatus SelectByPk(Int32 constaId)
        {
            using (var db = Sys.NewDb())
            {
                return db.SelectSingle<ContractStatus>(string.Format("ConStaID={0}", constaId));
            }
            
        }

        public static ContractStatus SelectByCode(string constaCode)
        {
            using (var db = Sys.NewDb())
            {
                return db.SelectSingle<ContractStatus>(string.Format("ConStaCode='{0}'", constaCode));
            }
            
        }

        public static int DeleteByPk(Int32 constaId)
        {
            using (var db = Sys.NewDb())
            {
                return db.Delete<ContractStatus>(string.Format("ConStaID={0}", constaId));
            }
            
        }
    }
}